Re: problems with pg_dump and pg_restore - Mailing list pgsql-admin

From admin@usachurch.com
Subject Re: problems with pg_dump and pg_restore
Date
Msg-id p0611040abd8b3defd798@[192.168.123.110]
Whole thread Raw
In response to Re: problems with pg_dump and pg_restore  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
>  > pg_restore -U admin -C -d staging /home/postgres/staging-dump
>>  pg_restore: [archiver (db)] could not execute query: ERROR:  database
>>  "staging" already exists
>
>-C tells it to create (and then connect to) the target DB, rather than
>connect to an existing DB and restore into that.  So generally you want
>to say "-d template1" (or some other existing DB) when you use -C.

Tom,

But if I first "dropdb -U admin staging", and then issue:
pg_restore -U admin -C -d staging /home/postgres/staging-dump

I get the error:
pg_restore: [archiver (db)] connection to database "staging" failed:
FATAL:  database "staging" does not exist

Yet the docs state that the above command should Create the database
named by the "-d staging"
part of the command.  I'm confused as to why that doesn't work.  I
also am not sure what the
template1 and template0 are there for.

Regards,
Devin

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: [Fwd: Re: Question about pgfsck]
Next
From: "Simon Riggs"
Date:
Subject: Re: Multiple WALs for PITR ?